import copy
import random

from src.config import config as cfg

print("this is Brick.py")


# 食物类
# 方法： 放置/移除
# 点以25为单位
class Brick:
    # 初始化各种需要的属性 [开始时默认向右/身体块x5]
    def __init__(self):
        self.bricks = []

    # # 无论何时 都在前端增加蛇块
    # def create_one_brick(self, i, j):
    #     node = (i, j, 1)
    #     return self.bricks.append(node)

    def load_stage(self, stage):
        stages = cfg.MAP_DATA
        size = len(stages)
        if stage > size:
            return False

        bricks = stages[stage - 1]['bricks']
        new = []
        for raw in bricks:
            new_raw = []
            for v in raw:
                new_raw.append(random.randint(1, 10) * v)
            new.append(new_raw)

        self.bricks = new

        return True

    def has_stage(self, stage):
        stages = cfg.MAP_DATA
        size = len(stages)
        return stage <= size
